import 'package:flutter/material.dart';
import 'package:flutter_study_app/app/router/routers.dart';
import 'package:flutter_study_app/widget/my_app_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class StorageSpecialRegionSearchPage extends StatefulWidget {
  String? name;
  StorageSpecialRegionSearchPage({this.name});

  @override
  State<StatefulWidget> createState() => _StorageSpecialRegionSearchPageState();
}

class _StorageSpecialRegionSearchPageState
    extends State<StorageSpecialRegionSearchPage> {
  TextEditingController _editingController = TextEditingController();

  @override
  void initState() {
    super.initState();
    _editingController.text = widget.name ?? "";
  }

  @override
  void dispose() {
    _editingController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: MyAppBar(
        title: '客户查询',
        showDivider: true,
        rightMenu: InkWell(
          onTap: () {
            _editingController.text = "";
          },
          child: Container(
            alignment: Alignment.center,
            padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 10.w),
            child: Text(
              '清除',
              style: TextStyle(color: Color(0xFF666666), fontSize: 14.sp),
            ),
          ),
        ),
      ),
      body: Column(
        children: [
          Container(
            color: Colors.white,
            height: 45.w,
            padding: EdgeInsets.symmetric(horizontal: 12.w),
            child: Row(
              children: [
                Text(
                  '客户名称',
                  style: TextStyle(color: Color(0xFF666666), fontSize: 14.sp),
                ),
                SizedBox(
                  width: 20.w,
                ),
                Expanded(
                    child: TextField(
                  controller: _editingController,
                  textAlign: TextAlign.right,
                  maxLines: 1,
                  style: TextStyle(fontSize: 14.sp, color: Color(0xFF333333)),
                  decoration: InputDecoration(
                    hintText: '请输入',
                    hintStyle:
                        TextStyle(fontSize: 14.sp, color: Color(0xFF999999)),
                    border: InputBorder.none,
                    focusedBorder: InputBorder.none,
                    disabledBorder: InputBorder.none,
                  ),
                ))
              ],
            ),
          ),
          Spacer(),
          SafeArea(
            child: Container(
              padding: EdgeInsets.all(12.w),
              width: double.infinity,
              height: 74.w,
              color: Colors.white,
              child: TextButton(
                style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(Color(0xff009868)),
                ),
                onPressed: () {
                  Map result = {"name": _editingController.text.trim()};
                  Routers.goBackWithParams(context, result);
                },
                child: Text(
                  '搜索',
                  style: TextStyle(color: Colors.white, fontSize: 18.sp),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
